package com.tuda.system.model;

import io.swagger.annotations.ApiModelProperty;

/**
 * @author Ys
 * @version 1.0
 * @date 2023/07/14 16:04
 */
public class PageUtil {

    @ApiModelProperty("页码")
    private Integer pageNum = 0;

    @ApiModelProperty("一页展示条数")
    private Integer pageSize = 10;

    public PageUtil(){
        this.pageSize = 10;
    }

    public Integer getPageNum() {
        if(pageSize == null || pageSize == 0) {
            pageSize = 10;
        }
        if(pageNum == null || pageNum == 0) {
            pageNum = 0;
        }else {
            if (pageNum < 1) {
                pageNum = 1;
            } else {
                pageNum = pageSize * (pageNum - 1);
            }
        }
        return pageNum;
    }

    public void setPageNum(Integer pageNum) {
        this.pageNum = pageNum;
    }

    public Integer getPageSize() {
        if(pageSize == null || pageSize == 0) {
            pageSize = 10;
        }
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }
}
